import { createApp } from 'vue'

import App from './App.vue'

//路由
import router from './router'

//pinia
import pinia from './store'

import 'normalize.css'

//element-plus 样式
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'

//vxe-table 样式
import 'vxe-table/lib/style.css'

//vxe-ui 样式
import 'vxe-pc-ui/lib/style.css'
import '@vxe-ui/plugin-render-element/dist/style.css'

//全局样式
import './styles/index.scss'

//全局svg
import { loadSvg } from '@/icons'

//全局插件 element antd
import { loadPlugins } from '@/plugins'

//全局指令
import { loadDirectives } from '@/directives'

//全局组件
import { loadComponents } from '@/components'

//全局方法
import { loadGlobalMethods } from '@/utils/install'

import '@/router/permission'

// vue i18n
import { i18n } from '@/languages/index'

const app = createApp(App)

// 加载插件
loadPlugins(app)

//加载全局 SVG
loadSvg(app)

// 挂载全局组件
loadComponents(app)

// 加载自定义指令
loadDirectives(app)

// 挂载全局方法
loadGlobalMethods(app)

// 在主入口监听PWA注册事件
window.addEventListener('beforeinstallprompt', e => {
  e.preventDefault()
  window.deferredPrompt = e
})

app.use(pinia).use(router).use(i18n)
router.isReady().then(() => {
  app.mount('#app')
})
